#include<stdio.h>
void LargestTwo(int a[], int n, int *pfirst, int *psecond)
{
    
    for(int i = 1; i < n; i ++)//注意i从1开始
    {
        if(a[i] > *pfirst)
        {
            int t = a[i];
            a[i] = *pfirst;
            *pfirst = t;
        }
    }
    for(int i = 2; i < n; i ++)
    {
        if(a[i] > *psecond)
        {
            int t = a[i];
            a[i] = *psecond;
            *psecond = t;
        }
    }
}
int main()
{
    int n;
    scanf("%d", &n);
    int a[1010];
    for(int i = 0; i < n; i ++)
    {
        scanf("%d ", &a[i]);
    }
    int first = 0, second = 0;
    LargestTwo(a, n, &a[0], &a[1]);//传的一定是地址
    printf("%d %d", a[0], a[1]);
    return 0;
}